package com.xishu.handler;

import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.DateUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDataFormatter extends DataFormatter {
    @Override
    public String formatRawCellContents(double value, int formatIndex, String formatString) {
        if (!formatString.equals("General")) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date javaDate = DateUtil.getJavaDate(value,false);
            return simpleDateFormat.format(javaDate);
        }
        return super.formatRawCellContents(value, formatIndex, formatString);
    }
}
